/*
	ChibiOS-NRF-Driver - Copyright (C) 2012
			Joel Bodenmann aka Tectu <joel@unormal.org>
			Paul Honig aka Ranzbak <paul@swarmtv.nl>

	This file is part of ChibiOS-NRF-Driver.

	ChibiOS-NRF-Driver is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	ChibiOS-NRF-Driver is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef NRF24L01_H
#define NRF24L01_H

#include "nrf_lld.h"

/*
* Define IRQ an CE PORT/PAD
* Make sure to setup the IRQ pad with the EXT driver as well
*/
#define NRF_PORT_CE_IRQ		IOPORT3
#define NRF_PORT_IRQ		4
#define NRF_PORT_CE			5

/*
 * Initialize the NRF24L01 Wifi chip.
 */
void NRFInit(NRFDriver *nrf);

/*
 * Set channel
 * Frequency is F0= 2400 + RF_CH [MHz]
 */
void NRFSetChannel(uint8_t chan);

/*
 * Handle the IRQ signal, unlock the Semaphores or set flags.
 */
void NRFHandleIrq(void);

/*
 * NRF24L01 test
 */
void NRFtest(void);

/*
 * Function to send data
 * This functions blocks until data is available
 * The send output buffer needs to be NRF_FIFO_BYTES(32) bytes wide
 */
void NRFSendData(uint8_t *inBuf);

/*
 * Routine to unlock IRQ handling.
 */
void NRFReportIRQ(void);

/*
 * Function to receive data from FIFO
 * This functions blocks until data is available
 * The output buffer needs to be NRF_FIFO_BYTES(32) bytes wide
 */
void NRFReceiveData(uint8_t *pipeNr, uint8_t *outBuf);

#endif /* NRF24L01_H */

